package com.wn.web;

import com.github.pagehelper.PageInfo;
import com.wn.common.pojo.PageParam;
import com.wn.common.pojo.ResProduct;
import com.wn.common.pojo.Rsp;
import com.wn.service.ResProductService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestControllerAdvice
@RequestMapping("ResProduct")
@Api(value = "菜品详情接口",description = "菜品详情接口")
public class ResProductController {
    @Autowired
    private ResProductService resProductService;

    @PostMapping("QueryAll")
    public Rsp QueryAll(@RequestBody PageParam<ResProduct> pageParam){
        return resProductService.QueryAll(pageParam);
    }

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @PostMapping("getProductById")
    public Rsp getProductById( Integer id , @RequestHeader(value = "userId") String userId){

        return resProductService.getProductById(id);
    }

    /**
     * 根据主键进行删除（物理删除）
     * @param id
     * @return
     */
    @PostMapping("deleteByPrimairyId")
    public Rsp deleteByPrimairyId(Integer id){
        return  resProductService.deleteByPrimairyId(id);
    }

    /**
     * 插入所有
     * @param resProduct
     * @return
     */
    @PostMapping("insertAll")
    public Rsp insertAll(@Valid ResProduct resProduct){
        return resProductService.insertAll(resProduct);
    }

    /**
     * 更新数据
     * @param resProduct
     * @return
     */
    @PostMapping("updateById")
    public Rsp updateById(@Valid ResProduct resProduct){
        return resProductService.updateById(resProduct);
    }
}
